/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vijayan.profile.service.persistence;

import com.liferay.portal.NoSuchModelException;
import com.liferay.portal.kernel.annotation.BeanReference;
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
import com.liferay.portal.kernel.dao.jdbc.RowMapper;
import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.InstanceFactory;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.ModelListener;
import com.liferay.portal.service.persistence.BatchSessionUtil;
import com.liferay.portal.service.persistence.ResourcePersistence;
import com.liferay.portal.service.persistence.UserPersistence;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;

import com.vijayan.profile.NoSuchProfileException;
import com.vijayan.profile.model.Profile;
import com.vijayan.profile.model.impl.ProfileImpl;
import com.vijayan.profile.model.impl.ProfileModelImpl;

import java.io.Serializable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * The persistence implementation for the profile service.
 *
 * <p>
 * Never modify or reference this class directly. Always use {@link ProfileUtil} to access the profile persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
 * </p>
 *
 * <p>
 * Caching information and settings can be found in <code>portal.properties</code>
 * </p>
 *
 * @author vijayan
 * @see ProfilePersistence
 * @see ProfileUtil
 * @generated
 */
public class ProfilePersistenceImpl extends BasePersistenceImpl<Profile>
	implements ProfilePersistence {
	public static final String FINDER_CLASS_NAME_ENTITY = ProfileImpl.class.getName();
	public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
		".List";
	public static final FinderPath FINDER_PATH_FETCH_BY_PROFILECODE = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
			"fetchByProfileCode", new String[] { String.class.getName() });
	public static final FinderPath FINDER_PATH_COUNT_BY_PROFILECODE = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"countByProfileCode", new String[] { String.class.getName() });
	public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"findByUserId",
			new String[] {
				Long.class.getName(),
				
			"java.lang.Integer", "java.lang.Integer",
				"com.liferay.portal.kernel.util.OrderByComparator"
			});
	public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"countByUserId", new String[] { Long.class.getName() });
	public static final FinderPath FINDER_PATH_FIND_BY_ADDEDBY = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"findByAddedBy",
			new String[] {
				Long.class.getName(),
				
			"java.lang.Integer", "java.lang.Integer",
				"com.liferay.portal.kernel.util.OrderByComparator"
			});
	public static final FinderPath FINDER_PATH_COUNT_BY_ADDEDBY = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"countByAddedBy", new String[] { Long.class.getName() });
	public static final FinderPath FINDER_PATH_FIND_BY_STATUS = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"findByStatus",
			new String[] {
				Integer.class.getName(),
				
			"java.lang.Integer", "java.lang.Integer",
				"com.liferay.portal.kernel.util.OrderByComparator"
			});
	public static final FinderPath FINDER_PATH_COUNT_BY_STATUS = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"countByStatus", new String[] { Integer.class.getName() });
	public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"findAll", new String[0]);
	public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
			"countAll", new String[0]);

	/**
	 * Caches the profile in the entity cache if it is enabled.
	 *
	 * @param profile the profile to cache
	 */
	public void cacheResult(Profile profile) {
		EntityCacheUtil.putResult(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileImpl.class, profile.getPrimaryKey(), profile);

		FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PROFILECODE,
			new Object[] { profile.getProfileCode() }, profile);
	}

	/**
	 * Caches the profiles in the entity cache if it is enabled.
	 *
	 * @param profiles the profiles to cache
	 */
	public void cacheResult(List<Profile> profiles) {
		for (Profile profile : profiles) {
			if (EntityCacheUtil.getResult(
						ProfileModelImpl.ENTITY_CACHE_ENABLED,
						ProfileImpl.class, profile.getPrimaryKey(), this) == null) {
				cacheResult(profile);
			}
		}
	}

	/**
	 * Clears the cache for all profiles.
	 *
	 * <p>
	 * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
	 * </p>
	 */
	public void clearCache() {
		CacheRegistryUtil.clear(ProfileImpl.class.getName());
		EntityCacheUtil.clearCache(ProfileImpl.class.getName());
		FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
		FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
	}

	/**
	 * Clears the cache for the profile.
	 *
	 * <p>
	 * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
	 * </p>
	 */
	public void clearCache(Profile profile) {
		EntityCacheUtil.removeResult(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileImpl.class, profile.getPrimaryKey());

		FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PROFILECODE,
			new Object[] { profile.getProfileCode() });
	}

	/**
	 * Creates a new profile with the primary key. Does not add the profile to the database.
	 *
	 * @param profileId the primary key for the new profile
	 * @return the new profile
	 */
	public Profile create(long profileId) {
		Profile profile = new ProfileImpl();

		profile.setNew(true);
		profile.setPrimaryKey(profileId);

		return profile;
	}

	/**
	 * Removes the profile with the primary key from the database. Also notifies the appropriate model listeners.
	 *
	 * @param primaryKey the primary key of the profile to remove
	 * @return the profile that was removed
	 * @throws com.liferay.portal.NoSuchModelException if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile remove(Serializable primaryKey)
		throws NoSuchModelException, SystemException {
		return remove(((Long)primaryKey).longValue());
	}

	/**
	 * Removes the profile with the primary key from the database. Also notifies the appropriate model listeners.
	 *
	 * @param profileId the primary key of the profile to remove
	 * @return the profile that was removed
	 * @throws com.vijayan.profile.NoSuchProfileException if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile remove(long profileId)
		throws NoSuchProfileException, SystemException {
		Session session = null;

		try {
			session = openSession();

			Profile profile = (Profile)session.get(ProfileImpl.class,
					new Long(profileId));

			if (profile == null) {
				if (_log.isWarnEnabled()) {
					_log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + profileId);
				}

				throw new NoSuchProfileException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
					profileId);
			}

			return remove(profile);
		}
		catch (NoSuchProfileException nsee) {
			throw nsee;
		}
		catch (Exception e) {
			throw processException(e);
		}
		finally {
			closeSession(session);
		}
	}

	protected Profile removeImpl(Profile profile) throws SystemException {
		profile = toUnwrappedModel(profile);

		Session session = null;

		try {
			session = openSession();

			if (profile.isCachedModel() || BatchSessionUtil.isEnabled()) {
				Object staleObject = session.get(ProfileImpl.class,
						profile.getPrimaryKeyObj());

				if (staleObject != null) {
					session.evict(staleObject);
				}
			}

			session.delete(profile);

			session.flush();
		}
		catch (Exception e) {
			throw processException(e);
		}
		finally {
			closeSession(session);
		}

		FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

		ProfileModelImpl profileModelImpl = (ProfileModelImpl)profile;

		FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PROFILECODE,
			new Object[] { profileModelImpl.getOriginalProfileCode() });

		EntityCacheUtil.removeResult(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileImpl.class, profile.getPrimaryKey());

		return profile;
	}

	public Profile updateImpl(com.vijayan.profile.model.Profile profile,
		boolean merge) throws SystemException {
		profile = toUnwrappedModel(profile);

		boolean isNew = profile.isNew();

		ProfileModelImpl profileModelImpl = (ProfileModelImpl)profile;

		Session session = null;

		try {
			session = openSession();

			BatchSessionUtil.update(session, profile, merge);

			profile.setNew(false);
		}
		catch (Exception e) {
			throw processException(e);
		}
		finally {
			closeSession(session);
		}

		FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

		EntityCacheUtil.putResult(ProfileModelImpl.ENTITY_CACHE_ENABLED,
			ProfileImpl.class, profile.getPrimaryKey(), profile);

		if (!isNew &&
				(!Validator.equals(profile.getProfileCode(),
					profileModelImpl.getOriginalProfileCode()))) {
			FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PROFILECODE,
				new Object[] { profileModelImpl.getOriginalProfileCode() });
		}

		if (isNew ||
				(!Validator.equals(profile.getProfileCode(),
					profileModelImpl.getOriginalProfileCode()))) {
			FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PROFILECODE,
				new Object[] { profile.getProfileCode() }, profile);
		}

		return profile;
	}

	protected Profile toUnwrappedModel(Profile profile) {
		if (profile instanceof ProfileImpl) {
			return profile;
		}

		ProfileImpl profileImpl = new ProfileImpl();

		profileImpl.setNew(profile.isNew());
		profileImpl.setPrimaryKey(profile.getPrimaryKey());

		profileImpl.setProfileId(profile.getProfileId());
		profileImpl.setProfileCode(profile.getProfileCode());
		profileImpl.setCreatedForMy(profile.getCreatedForMy());
		profileImpl.setProfileName(profile.getProfileName());
		profileImpl.setGender(profile.isGender());
		profileImpl.setBirthDateWithTime(profile.getBirthDateWithTime());
		profileImpl.setRasi(profile.getRasi());
		profileImpl.setStar(profile.getStar());
		profileImpl.setDosam(profile.getDosam());
		profileImpl.setReligion(profile.getReligion());
		profileImpl.setCaste(profile.getCaste());
		profileImpl.setSubcaste(profile.getSubcaste());
		profileImpl.setHeight(profile.getHeight());
		profileImpl.setWeight(profile.getWeight());
		profileImpl.setComplexion(profile.getComplexion());
		profileImpl.setMotherTongue(profile.getMotherTongue());
		profileImpl.setLanguageKnown(profile.getLanguageKnown());
		profileImpl.setMaritalStatus(profile.getMaritalStatus());
		profileImpl.setChildren(profile.getChildren());
		profileImpl.setResidingCountry(profile.getResidingCountry());
		profileImpl.setResidingState(profile.getResidingState());
		profileImpl.setResidingCity(profile.getResidingCity());
		profileImpl.setAddress(profile.getAddress());
		profileImpl.setPostalCode(profile.getPostalCode());
		profileImpl.setHomePhone(profile.getHomePhone());
		profileImpl.setMobile(profile.getMobile());
		profileImpl.setEmailAddress(profile.getEmailAddress());
		profileImpl.setEducation(profile.getEducation());
		profileImpl.setProfession(profile.getProfession());
		profileImpl.setCurrency(profile.getCurrency());
		profileImpl.setAnnualIncome(profile.getAnnualIncome());
		profileImpl.setHobbies(profile.getHobbies());
		profileImpl.setAboutMe(profile.getAboutMe());
		profileImpl.setFamilyValue(profile.getFamilyValue());
		profileImpl.setFamilyType(profile.getFamilyType());
		profileImpl.setFamilyStatus(profile.getFamilyStatus());
		profileImpl.setSecurityNo1(profile.getSecurityNo1());
		profileImpl.setSecurityNo2(profile.getSecurityNo2());
		profileImpl.setPhotoSecurityCode(profile.getPhotoSecurityCode());
		profileImpl.setLastLoggedIn(profile.getLastLoggedIn());
		profileImpl.setStatus(profile.getStatus());
		profileImpl.setAge(profile.getAge());
		profileImpl.setScheme(profile.getScheme());
		profileImpl.setHoroscope(profile.isHoroscope());
		profileImpl.setAddedBy(profile.getAddedBy());
		profileImpl.setDateAdded(profile.getDateAdded());
		profileImpl.setDateModified(profile.getDateModified());
		profileImpl.setModifiedBy(profile.getModifiedBy());
		profileImpl.setModifiedCount(profile.getModifiedCount());
		profileImpl.setCompanyId(profile.getCompanyId());
		profileImpl.setGroupId(profile.getGroupId());

		return profileImpl;
	}

	/**
	 * Finds the profile with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
	 *
	 * @param primaryKey the primary key of the profile to find
	 * @return the profile
	 * @throws com.liferay.portal.NoSuchModelException if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByPrimaryKey(Serializable primaryKey)
		throws NoSuchModelException, SystemException {
		return findByPrimaryKey(((Long)primaryKey).longValue());
	}

	/**
	 * Finds the profile with the primary key or throws a {@link com.vijayan.profile.NoSuchProfileException} if it could not be found.
	 *
	 * @param profileId the primary key of the profile to find
	 * @return the profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByPrimaryKey(long profileId)
		throws NoSuchProfileException, SystemException {
		Profile profile = fetchByPrimaryKey(profileId);

		if (profile == null) {
			if (_log.isWarnEnabled()) {
				_log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + profileId);
			}

			throw new NoSuchProfileException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
				profileId);
		}

		return profile;
	}

	/**
	 * Finds the profile with the primary key or returns <code>null</code> if it could not be found.
	 *
	 * @param primaryKey the primary key of the profile to find
	 * @return the profile, or <code>null</code> if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile fetchByPrimaryKey(Serializable primaryKey)
		throws SystemException {
		return fetchByPrimaryKey(((Long)primaryKey).longValue());
	}

	/**
	 * Finds the profile with the primary key or returns <code>null</code> if it could not be found.
	 *
	 * @param profileId the primary key of the profile to find
	 * @return the profile, or <code>null</code> if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile fetchByPrimaryKey(long profileId) throws SystemException {
		Profile profile = (Profile)EntityCacheUtil.getResult(ProfileModelImpl.ENTITY_CACHE_ENABLED,
				ProfileImpl.class, profileId, this);

		if (profile == null) {
			Session session = null;

			try {
				session = openSession();

				profile = (Profile)session.get(ProfileImpl.class,
						new Long(profileId));
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (profile != null) {
					cacheResult(profile);
				}

				closeSession(session);
			}
		}

		return profile;
	}

	/**
	 * Finds the profile where profileCode = &#63; or throws a {@link com.vijayan.profile.NoSuchProfileException} if it could not be found.
	 *
	 * @param profileCode the profile code to search with
	 * @return the matching profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByProfileCode(String profileCode)
		throws NoSuchProfileException, SystemException {
		Profile profile = fetchByProfileCode(profileCode);

		if (profile == null) {
			StringBundler msg = new StringBundler(4);

			msg.append(_NO_SUCH_ENTITY_WITH_KEY);

			msg.append("profileCode=");
			msg.append(profileCode);

			msg.append(StringPool.CLOSE_CURLY_BRACE);

			if (_log.isWarnEnabled()) {
				_log.warn(msg.toString());
			}

			throw new NoSuchProfileException(msg.toString());
		}

		return profile;
	}

	/**
	 * Finds the profile where profileCode = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
	 *
	 * @param profileCode the profile code to search with
	 * @return the matching profile, or <code>null</code> if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile fetchByProfileCode(String profileCode)
		throws SystemException {
		return fetchByProfileCode(profileCode, true);
	}

	/**
	 * Finds the profile where profileCode = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
	 *
	 * @param profileCode the profile code to search with
	 * @return the matching profile, or <code>null</code> if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile fetchByProfileCode(String profileCode,
		boolean retrieveFromCache) throws SystemException {
		Object[] finderArgs = new Object[] { profileCode };

		Object result = null;

		if (retrieveFromCache) {
			result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PROFILECODE,
					finderArgs, this);
		}

		if (result == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = new StringBundler(3);

				query.append(_SQL_SELECT_PROFILE_WHERE);

				if (profileCode == null) {
					query.append(_FINDER_COLUMN_PROFILECODE_PROFILECODE_1);
				}
				else {
					if (profileCode.equals(StringPool.BLANK)) {
						query.append(_FINDER_COLUMN_PROFILECODE_PROFILECODE_3);
					}
					else {
						query.append(_FINDER_COLUMN_PROFILECODE_PROFILECODE_2);
					}
				}

				query.append(ProfileModelImpl.ORDER_BY_JPQL);

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				if (profileCode != null) {
					qPos.add(profileCode);
				}

				List<Profile> list = q.list();

				result = list;

				Profile profile = null;

				if (list.isEmpty()) {
					FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PROFILECODE,
						finderArgs, list);
				}
				else {
					profile = list.get(0);

					cacheResult(profile);

					if ((profile.getProfileCode() == null) ||
							!profile.getProfileCode().equals(profileCode)) {
						FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PROFILECODE,
							finderArgs, profile);
					}
				}

				return profile;
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (result == null) {
					FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PROFILECODE,
						finderArgs, new ArrayList<Profile>());
				}

				closeSession(session);
			}
		}
		else {
			if (result instanceof List<?>) {
				return null;
			}
			else {
				return (Profile)result;
			}
		}
	}

	/**
	 * Finds all the profiles where addedBy = &#63;.
	 *
	 * @param addedBy the added by to search with
	 * @return the matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByUserId(long addedBy) throws SystemException {
		return findByUserId(addedBy, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}

	/**
	 * Finds a range of all the profiles where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByUserId(long addedBy, int start, int end)
		throws SystemException {
		return findByUserId(addedBy, start, end, null);
	}

	/**
	 * Finds an ordered range of all the profiles where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByUserId(long addedBy, int start, int end,
		OrderByComparator orderByComparator) throws SystemException {
		Object[] finderArgs = new Object[] {
				addedBy,
				
				String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<Profile> list = (List<Profile>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = null;

				if (orderByComparator != null) {
					query = new StringBundler(3 +
							(orderByComparator.getOrderByFields().length * 3));
				}
				else {
					query = new StringBundler(3);
				}

				query.append(_SQL_SELECT_PROFILE_WHERE);

				query.append(_FINDER_COLUMN_USERID_ADDEDBY_2);

				if (orderByComparator != null) {
					appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
						orderByComparator);
				}

				else {
					query.append(ProfileModelImpl.ORDER_BY_JPQL);
				}

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(addedBy);

				list = (List<Profile>)QueryUtil.list(q, getDialect(), start, end);
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<Profile>();
				}

				cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
					finderArgs, list);

				closeSession(session);
			}
		}

		return list;
	}

	/**
	 * Finds the first profile in the ordered set where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the first matching profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByUserId_First(long addedBy,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		List<Profile> list = findByUserId(addedBy, 0, 1, orderByComparator);

		if (list.isEmpty()) {
			StringBundler msg = new StringBundler(4);

			msg.append(_NO_SUCH_ENTITY_WITH_KEY);

			msg.append("addedBy=");
			msg.append(addedBy);

			msg.append(StringPool.CLOSE_CURLY_BRACE);

			throw new NoSuchProfileException(msg.toString());
		}
		else {
			return list.get(0);
		}
	}

	/**
	 * Finds the last profile in the ordered set where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the last matching profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByUserId_Last(long addedBy,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		int count = countByUserId(addedBy);

		List<Profile> list = findByUserId(addedBy, count - 1, count,
				orderByComparator);

		if (list.isEmpty()) {
			StringBundler msg = new StringBundler(4);

			msg.append(_NO_SUCH_ENTITY_WITH_KEY);

			msg.append("addedBy=");
			msg.append(addedBy);

			msg.append(StringPool.CLOSE_CURLY_BRACE);

			throw new NoSuchProfileException(msg.toString());
		}
		else {
			return list.get(0);
		}
	}

	/**
	 * Finds the profiles before and after the current profile in the ordered set where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param profileId the primary key of the current profile
	 * @param addedBy the added by to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the previous, current, and next profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile[] findByUserId_PrevAndNext(long profileId, long addedBy,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		Profile profile = findByPrimaryKey(profileId);

		Session session = null;

		try {
			session = openSession();

			Profile[] array = new ProfileImpl[3];

			array[0] = getByUserId_PrevAndNext(session, profile, addedBy,
					orderByComparator, true);

			array[1] = profile;

			array[2] = getByUserId_PrevAndNext(session, profile, addedBy,
					orderByComparator, false);

			return array;
		}
		catch (Exception e) {
			throw processException(e);
		}
		finally {
			closeSession(session);
		}
	}

	protected Profile getByUserId_PrevAndNext(Session session, Profile profile,
		long addedBy, OrderByComparator orderByComparator, boolean previous) {
		StringBundler query = null;

		if (orderByComparator != null) {
			query = new StringBundler(6 +
					(orderByComparator.getOrderByFields().length * 6));
		}
		else {
			query = new StringBundler(3);
		}

		query.append(_SQL_SELECT_PROFILE_WHERE);

		query.append(_FINDER_COLUMN_USERID_ADDEDBY_2);

		if (orderByComparator != null) {
			String[] orderByFields = orderByComparator.getOrderByFields();

			if (orderByFields.length > 0) {
				query.append(WHERE_AND);
			}

			for (int i = 0; i < orderByFields.length; i++) {
				query.append(_ORDER_BY_ENTITY_ALIAS);
				query.append(orderByFields[i]);

				if ((i + 1) < orderByFields.length) {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(WHERE_GREATER_THAN_HAS_NEXT);
					}
					else {
						query.append(WHERE_LESSER_THAN_HAS_NEXT);
					}
				}
				else {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(WHERE_GREATER_THAN);
					}
					else {
						query.append(WHERE_LESSER_THAN);
					}
				}
			}

			query.append(ORDER_BY_CLAUSE);

			for (int i = 0; i < orderByFields.length; i++) {
				query.append(_ORDER_BY_ENTITY_ALIAS);
				query.append(orderByFields[i]);

				if ((i + 1) < orderByFields.length) {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(ORDER_BY_ASC_HAS_NEXT);
					}
					else {
						query.append(ORDER_BY_DESC_HAS_NEXT);
					}
				}
				else {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(ORDER_BY_ASC);
					}
					else {
						query.append(ORDER_BY_DESC);
					}
				}
			}
		}

		else {
			query.append(ProfileModelImpl.ORDER_BY_JPQL);
		}

		String sql = query.toString();

		Query q = session.createQuery(sql);

		q.setFirstResult(0);
		q.setMaxResults(2);

		QueryPos qPos = QueryPos.getInstance(q);

		qPos.add(addedBy);

		if (orderByComparator != null) {
			Object[] values = orderByComparator.getOrderByValues(profile);

			for (Object value : values) {
				qPos.add(value);
			}
		}

		List<Profile> list = q.list();

		if (list.size() == 2) {
			return list.get(1);
		}
		else {
			return null;
		}
	}

	/**
	 * Finds all the profiles where addedBy = &#63;.
	 *
	 * @param addedBy the added by to search with
	 * @return the matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByAddedBy(long addedBy) throws SystemException {
		return findByAddedBy(addedBy, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}

	/**
	 * Finds a range of all the profiles where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByAddedBy(long addedBy, int start, int end)
		throws SystemException {
		return findByAddedBy(addedBy, start, end, null);
	}

	/**
	 * Finds an ordered range of all the profiles where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByAddedBy(long addedBy, int start, int end,
		OrderByComparator orderByComparator) throws SystemException {
		Object[] finderArgs = new Object[] {
				addedBy,
				
				String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<Profile> list = (List<Profile>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ADDEDBY,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = null;

				if (orderByComparator != null) {
					query = new StringBundler(3 +
							(orderByComparator.getOrderByFields().length * 3));
				}
				else {
					query = new StringBundler(3);
				}

				query.append(_SQL_SELECT_PROFILE_WHERE);

				query.append(_FINDER_COLUMN_ADDEDBY_ADDEDBY_2);

				if (orderByComparator != null) {
					appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
						orderByComparator);
				}

				else {
					query.append(ProfileModelImpl.ORDER_BY_JPQL);
				}

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(addedBy);

				list = (List<Profile>)QueryUtil.list(q, getDialect(), start, end);
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<Profile>();
				}

				cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ADDEDBY,
					finderArgs, list);

				closeSession(session);
			}
		}

		return list;
	}

	/**
	 * Finds the first profile in the ordered set where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the first matching profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByAddedBy_First(long addedBy,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		List<Profile> list = findByAddedBy(addedBy, 0, 1, orderByComparator);

		if (list.isEmpty()) {
			StringBundler msg = new StringBundler(4);

			msg.append(_NO_SUCH_ENTITY_WITH_KEY);

			msg.append("addedBy=");
			msg.append(addedBy);

			msg.append(StringPool.CLOSE_CURLY_BRACE);

			throw new NoSuchProfileException(msg.toString());
		}
		else {
			return list.get(0);
		}
	}

	/**
	 * Finds the last profile in the ordered set where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param addedBy the added by to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the last matching profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByAddedBy_Last(long addedBy,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		int count = countByAddedBy(addedBy);

		List<Profile> list = findByAddedBy(addedBy, count - 1, count,
				orderByComparator);

		if (list.isEmpty()) {
			StringBundler msg = new StringBundler(4);

			msg.append(_NO_SUCH_ENTITY_WITH_KEY);

			msg.append("addedBy=");
			msg.append(addedBy);

			msg.append(StringPool.CLOSE_CURLY_BRACE);

			throw new NoSuchProfileException(msg.toString());
		}
		else {
			return list.get(0);
		}
	}

	/**
	 * Finds the profiles before and after the current profile in the ordered set where addedBy = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param profileId the primary key of the current profile
	 * @param addedBy the added by to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the previous, current, and next profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile[] findByAddedBy_PrevAndNext(long profileId, long addedBy,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		Profile profile = findByPrimaryKey(profileId);

		Session session = null;

		try {
			session = openSession();

			Profile[] array = new ProfileImpl[3];

			array[0] = getByAddedBy_PrevAndNext(session, profile, addedBy,
					orderByComparator, true);

			array[1] = profile;

			array[2] = getByAddedBy_PrevAndNext(session, profile, addedBy,
					orderByComparator, false);

			return array;
		}
		catch (Exception e) {
			throw processException(e);
		}
		finally {
			closeSession(session);
		}
	}

	protected Profile getByAddedBy_PrevAndNext(Session session,
		Profile profile, long addedBy, OrderByComparator orderByComparator,
		boolean previous) {
		StringBundler query = null;

		if (orderByComparator != null) {
			query = new StringBundler(6 +
					(orderByComparator.getOrderByFields().length * 6));
		}
		else {
			query = new StringBundler(3);
		}

		query.append(_SQL_SELECT_PROFILE_WHERE);

		query.append(_FINDER_COLUMN_ADDEDBY_ADDEDBY_2);

		if (orderByComparator != null) {
			String[] orderByFields = orderByComparator.getOrderByFields();

			if (orderByFields.length > 0) {
				query.append(WHERE_AND);
			}

			for (int i = 0; i < orderByFields.length; i++) {
				query.append(_ORDER_BY_ENTITY_ALIAS);
				query.append(orderByFields[i]);

				if ((i + 1) < orderByFields.length) {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(WHERE_GREATER_THAN_HAS_NEXT);
					}
					else {
						query.append(WHERE_LESSER_THAN_HAS_NEXT);
					}
				}
				else {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(WHERE_GREATER_THAN);
					}
					else {
						query.append(WHERE_LESSER_THAN);
					}
				}
			}

			query.append(ORDER_BY_CLAUSE);

			for (int i = 0; i < orderByFields.length; i++) {
				query.append(_ORDER_BY_ENTITY_ALIAS);
				query.append(orderByFields[i]);

				if ((i + 1) < orderByFields.length) {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(ORDER_BY_ASC_HAS_NEXT);
					}
					else {
						query.append(ORDER_BY_DESC_HAS_NEXT);
					}
				}
				else {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(ORDER_BY_ASC);
					}
					else {
						query.append(ORDER_BY_DESC);
					}
				}
			}
		}

		else {
			query.append(ProfileModelImpl.ORDER_BY_JPQL);
		}

		String sql = query.toString();

		Query q = session.createQuery(sql);

		q.setFirstResult(0);
		q.setMaxResults(2);

		QueryPos qPos = QueryPos.getInstance(q);

		qPos.add(addedBy);

		if (orderByComparator != null) {
			Object[] values = orderByComparator.getOrderByValues(profile);

			for (Object value : values) {
				qPos.add(value);
			}
		}

		List<Profile> list = q.list();

		if (list.size() == 2) {
			return list.get(1);
		}
		else {
			return null;
		}
	}

	/**
	 * Finds all the profiles where status = &#63;.
	 *
	 * @param status the status to search with
	 * @return the matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByStatus(int status) throws SystemException {
		return findByStatus(status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}

	/**
	 * Finds a range of all the profiles where status = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param status the status to search with
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByStatus(int status, int start, int end)
		throws SystemException {
		return findByStatus(status, start, end, null);
	}

	/**
	 * Finds an ordered range of all the profiles where status = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param status the status to search with
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findByStatus(int status, int start, int end,
		OrderByComparator orderByComparator) throws SystemException {
		Object[] finderArgs = new Object[] {
				status,
				
				String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<Profile> list = (List<Profile>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_STATUS,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = null;

				if (orderByComparator != null) {
					query = new StringBundler(3 +
							(orderByComparator.getOrderByFields().length * 3));
				}
				else {
					query = new StringBundler(3);
				}

				query.append(_SQL_SELECT_PROFILE_WHERE);

				query.append(_FINDER_COLUMN_STATUS_STATUS_2);

				if (orderByComparator != null) {
					appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
						orderByComparator);
				}

				else {
					query.append(ProfileModelImpl.ORDER_BY_JPQL);
				}

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(status);

				list = (List<Profile>)QueryUtil.list(q, getDialect(), start, end);
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<Profile>();
				}

				cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_STATUS,
					finderArgs, list);

				closeSession(session);
			}
		}

		return list;
	}

	/**
	 * Finds the first profile in the ordered set where status = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param status the status to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the first matching profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByStatus_First(int status,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		List<Profile> list = findByStatus(status, 0, 1, orderByComparator);

		if (list.isEmpty()) {
			StringBundler msg = new StringBundler(4);

			msg.append(_NO_SUCH_ENTITY_WITH_KEY);

			msg.append("status=");
			msg.append(status);

			msg.append(StringPool.CLOSE_CURLY_BRACE);

			throw new NoSuchProfileException(msg.toString());
		}
		else {
			return list.get(0);
		}
	}

	/**
	 * Finds the last profile in the ordered set where status = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param status the status to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the last matching profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a matching profile could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile findByStatus_Last(int status,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		int count = countByStatus(status);

		List<Profile> list = findByStatus(status, count - 1, count,
				orderByComparator);

		if (list.isEmpty()) {
			StringBundler msg = new StringBundler(4);

			msg.append(_NO_SUCH_ENTITY_WITH_KEY);

			msg.append("status=");
			msg.append(status);

			msg.append(StringPool.CLOSE_CURLY_BRACE);

			throw new NoSuchProfileException(msg.toString());
		}
		else {
			return list.get(0);
		}
	}

	/**
	 * Finds the profiles before and after the current profile in the ordered set where status = &#63;.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param profileId the primary key of the current profile
	 * @param status the status to search with
	 * @param orderByComparator the comparator to order the set by
	 * @return the previous, current, and next profile
	 * @throws com.vijayan.profile.NoSuchProfileException if a profile with the primary key could not be found
	 * @throws SystemException if a system exception occurred
	 */
	public Profile[] findByStatus_PrevAndNext(long profileId, int status,
		OrderByComparator orderByComparator)
		throws NoSuchProfileException, SystemException {
		Profile profile = findByPrimaryKey(profileId);

		Session session = null;

		try {
			session = openSession();

			Profile[] array = new ProfileImpl[3];

			array[0] = getByStatus_PrevAndNext(session, profile, status,
					orderByComparator, true);

			array[1] = profile;

			array[2] = getByStatus_PrevAndNext(session, profile, status,
					orderByComparator, false);

			return array;
		}
		catch (Exception e) {
			throw processException(e);
		}
		finally {
			closeSession(session);
		}
	}

	protected Profile getByStatus_PrevAndNext(Session session, Profile profile,
		int status, OrderByComparator orderByComparator, boolean previous) {
		StringBundler query = null;

		if (orderByComparator != null) {
			query = new StringBundler(6 +
					(orderByComparator.getOrderByFields().length * 6));
		}
		else {
			query = new StringBundler(3);
		}

		query.append(_SQL_SELECT_PROFILE_WHERE);

		query.append(_FINDER_COLUMN_STATUS_STATUS_2);

		if (orderByComparator != null) {
			String[] orderByFields = orderByComparator.getOrderByFields();

			if (orderByFields.length > 0) {
				query.append(WHERE_AND);
			}

			for (int i = 0; i < orderByFields.length; i++) {
				query.append(_ORDER_BY_ENTITY_ALIAS);
				query.append(orderByFields[i]);

				if ((i + 1) < orderByFields.length) {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(WHERE_GREATER_THAN_HAS_NEXT);
					}
					else {
						query.append(WHERE_LESSER_THAN_HAS_NEXT);
					}
				}
				else {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(WHERE_GREATER_THAN);
					}
					else {
						query.append(WHERE_LESSER_THAN);
					}
				}
			}

			query.append(ORDER_BY_CLAUSE);

			for (int i = 0; i < orderByFields.length; i++) {
				query.append(_ORDER_BY_ENTITY_ALIAS);
				query.append(orderByFields[i]);

				if ((i + 1) < orderByFields.length) {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(ORDER_BY_ASC_HAS_NEXT);
					}
					else {
						query.append(ORDER_BY_DESC_HAS_NEXT);
					}
				}
				else {
					if (orderByComparator.isAscending() ^ previous) {
						query.append(ORDER_BY_ASC);
					}
					else {
						query.append(ORDER_BY_DESC);
					}
				}
			}
		}

		else {
			query.append(ProfileModelImpl.ORDER_BY_JPQL);
		}

		String sql = query.toString();

		Query q = session.createQuery(sql);

		q.setFirstResult(0);
		q.setMaxResults(2);

		QueryPos qPos = QueryPos.getInstance(q);

		qPos.add(status);

		if (orderByComparator != null) {
			Object[] values = orderByComparator.getOrderByValues(profile);

			for (Object value : values) {
				qPos.add(value);
			}
		}

		List<Profile> list = q.list();

		if (list.size() == 2) {
			return list.get(1);
		}
		else {
			return null;
		}
	}

	/**
	 * Finds all the profiles.
	 *
	 * @return the profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findAll() throws SystemException {
		return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}

	/**
	 * Finds a range of all the profiles.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findAll(int start, int end) throws SystemException {
		return findAll(start, end, null);
	}

	/**
	 * Finds an ordered range of all the profiles.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of profiles
	 * @throws SystemException if a system exception occurred
	 */
	public List<Profile> findAll(int start, int end,
		OrderByComparator orderByComparator) throws SystemException {
		Object[] finderArgs = new Object[] {
				String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<Profile> list = (List<Profile>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = null;
				String sql = null;

				if (orderByComparator != null) {
					query = new StringBundler(2 +
							(orderByComparator.getOrderByFields().length * 3));

					query.append(_SQL_SELECT_PROFILE);

					appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
						orderByComparator);

					sql = query.toString();
				}
				else {
					sql = _SQL_SELECT_PROFILE.concat(ProfileModelImpl.ORDER_BY_JPQL);
				}

				Query q = session.createQuery(sql);

				if (orderByComparator == null) {
					list = (List<Profile>)QueryUtil.list(q, getDialect(),
							start, end, false);

					Collections.sort(list);
				}
				else {
					list = (List<Profile>)QueryUtil.list(q, getDialect(),
							start, end);
				}
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<Profile>();
				}

				cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);

				closeSession(session);
			}
		}

		return list;
	}

	/**
	 * Removes the profile where profileCode = &#63; from the database.
	 *
	 * @param profileCode the profile code to search with
	 * @throws SystemException if a system exception occurred
	 */
	public void removeByProfileCode(String profileCode)
		throws NoSuchProfileException, SystemException {
		Profile profile = findByProfileCode(profileCode);

		remove(profile);
	}

	/**
	 * Removes all the profiles where addedBy = &#63; from the database.
	 *
	 * @param addedBy the added by to search with
	 * @throws SystemException if a system exception occurred
	 */
	public void removeByUserId(long addedBy) throws SystemException {
		for (Profile profile : findByUserId(addedBy)) {
			remove(profile);
		}
	}

	/**
	 * Removes all the profiles where addedBy = &#63; from the database.
	 *
	 * @param addedBy the added by to search with
	 * @throws SystemException if a system exception occurred
	 */
	public void removeByAddedBy(long addedBy) throws SystemException {
		for (Profile profile : findByAddedBy(addedBy)) {
			remove(profile);
		}
	}

	/**
	 * Removes all the profiles where status = &#63; from the database.
	 *
	 * @param status the status to search with
	 * @throws SystemException if a system exception occurred
	 */
	public void removeByStatus(int status) throws SystemException {
		for (Profile profile : findByStatus(status)) {
			remove(profile);
		}
	}

	/**
	 * Removes all the profiles from the database.
	 *
	 * @throws SystemException if a system exception occurred
	 */
	public void removeAll() throws SystemException {
		for (Profile profile : findAll()) {
			remove(profile);
		}
	}

	/**
	 * Counts all the profiles where profileCode = &#63;.
	 *
	 * @param profileCode the profile code to search with
	 * @return the number of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public int countByProfileCode(String profileCode) throws SystemException {
		Object[] finderArgs = new Object[] { profileCode };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PROFILECODE,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = new StringBundler(2);

				query.append(_SQL_COUNT_PROFILE_WHERE);

				if (profileCode == null) {
					query.append(_FINDER_COLUMN_PROFILECODE_PROFILECODE_1);
				}
				else {
					if (profileCode.equals(StringPool.BLANK)) {
						query.append(_FINDER_COLUMN_PROFILECODE_PROFILECODE_3);
					}
					else {
						query.append(_FINDER_COLUMN_PROFILECODE_PROFILECODE_2);
					}
				}

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				if (profileCode != null) {
					qPos.add(profileCode);
				}

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PROFILECODE,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	/**
	 * Counts all the profiles where addedBy = &#63;.
	 *
	 * @param addedBy the added by to search with
	 * @return the number of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public int countByUserId(long addedBy) throws SystemException {
		Object[] finderArgs = new Object[] { addedBy };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = new StringBundler(2);

				query.append(_SQL_COUNT_PROFILE_WHERE);

				query.append(_FINDER_COLUMN_USERID_ADDEDBY_2);

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(addedBy);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	/**
	 * Counts all the profiles where addedBy = &#63;.
	 *
	 * @param addedBy the added by to search with
	 * @return the number of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public int countByAddedBy(long addedBy) throws SystemException {
		Object[] finderArgs = new Object[] { addedBy };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ADDEDBY,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = new StringBundler(2);

				query.append(_SQL_COUNT_PROFILE_WHERE);

				query.append(_FINDER_COLUMN_ADDEDBY_ADDEDBY_2);

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(addedBy);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ADDEDBY,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	/**
	 * Counts all the profiles where status = &#63;.
	 *
	 * @param status the status to search with
	 * @return the number of matching profiles
	 * @throws SystemException if a system exception occurred
	 */
	public int countByStatus(int status) throws SystemException {
		Object[] finderArgs = new Object[] { status };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STATUS,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				StringBundler query = new StringBundler(2);

				query.append(_SQL_COUNT_PROFILE_WHERE);

				query.append(_FINDER_COLUMN_STATUS_STATUS_2);

				String sql = query.toString();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(status);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STATUS,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	/**
	 * Counts all the profiles.
	 *
	 * @return the number of profiles
	 * @throws SystemException if a system exception occurred
	 */
	public int countAll() throws SystemException {
		Object[] finderArgs = new Object[0];

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				Query q = session.createQuery(_SQL_COUNT_PROFILE);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
					count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	/**
	 * Gets all the my photos associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the associated my photos for
	 * @return the my photos associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.MyPhoto> getMyPhotos(long pk)
		throws SystemException {
		return getMyPhotos(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
	}

	/**
	 * Gets a range of all the my photos associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated my photos for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of my photos associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.MyPhoto> getMyPhotos(long pk,
		int start, int end) throws SystemException {
		return getMyPhotos(pk, start, end, null);
	}

	public static final FinderPath FINDER_PATH_GET_MYPHOTOS = new FinderPath(com.vijayan.profile.model.impl.MyPhotoModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.MyPhotoModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.MyPhotoPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getMyPhotos",
			new String[] {
				Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
				"com.liferay.portal.kernel.util.OrderByComparator"
			});

	/**
	 * Gets an ordered range of all the my photos associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated my photos for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of my photos associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.MyPhoto> getMyPhotos(long pk,
		int start, int end, OrderByComparator orderByComparator)
		throws SystemException {
		Object[] finderArgs = new Object[] {
				pk, String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<com.vijayan.profile.model.MyPhoto> list = (List<com.vijayan.profile.model.MyPhoto>)FinderCacheUtil.getResult(FINDER_PATH_GET_MYPHOTOS,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				String sql = null;

				if (orderByComparator != null) {
					sql = _SQL_GETMYPHOTOS.concat(ORDER_BY_CLAUSE)
										  .concat(orderByComparator.getOrderBy());
				}
				else {
					sql = _SQL_GETMYPHOTOS;
				}

				SQLQuery q = session.createSQLQuery(sql);

				q.addEntity("kalyan_photo",
					com.vijayan.profile.model.impl.MyPhotoImpl.class);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				list = (List<com.vijayan.profile.model.MyPhoto>)QueryUtil.list(q,
						getDialect(), start, end);
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<com.vijayan.profile.model.MyPhoto>();
				}

				myPhotoPersistence.cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_GET_MYPHOTOS, finderArgs,
					list);

				closeSession(session);
			}
		}

		return list;
	}

	public static final FinderPath FINDER_PATH_GET_MYPHOTOS_SIZE = new FinderPath(com.vijayan.profile.model.impl.MyPhotoModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.MyPhotoModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.MyPhotoPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getMyPhotosSize", new String[] { Long.class.getName() });

	/**
	 * Gets the number of my photos associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the number of associated my photos for
	 * @return the number of my photos associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public int getMyPhotosSize(long pk) throws SystemException {
		Object[] finderArgs = new Object[] { pk };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_MYPHOTOS_SIZE,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				SQLQuery q = session.createSQLQuery(_SQL_GETMYPHOTOSSIZE);

				q.addScalar(COUNT_COLUMN_NAME,
					com.liferay.portal.kernel.dao.orm.Type.LONG);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_GET_MYPHOTOS_SIZE,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	public static final FinderPath FINDER_PATH_CONTAINS_MYPHOTO = new FinderPath(com.vijayan.profile.model.impl.MyPhotoModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.MyPhotoModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.MyPhotoPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"containsMyPhoto",
			new String[] { Long.class.getName(), Long.class.getName() });

	/**
	 * Determines whether the my photo is associated with the profile.
	 *
	 * @param pk the primary key of the profile
	 * @param myPhotoPK the primary key of the my photo
	 * @return whether the my photo is associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsMyPhoto(long pk, long myPhotoPK)
		throws SystemException {
		Object[] finderArgs = new Object[] { pk, myPhotoPK };

		Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_MYPHOTO,
				finderArgs, this);

		if (value == null) {
			try {
				value = Boolean.valueOf(containsMyPhoto.contains(pk, myPhotoPK));
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (value == null) {
					value = Boolean.FALSE;
				}

				FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_MYPHOTO,
					finderArgs, value);
			}
		}

		return value.booleanValue();
	}

	/**
	 * Determines whether the profile has any my photos associated with it.
	 *
	 * @param pk the primary key of the profile to check for associations with my photos
	 * @return whether the profile has any my photos associated with it
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsMyPhotos(long pk) throws SystemException {
		if (getMyPhotosSize(pk) > 0) {
			return true;
		}
		else {
			return false;
		}
	}

	/**
	 * Gets all the my expectations associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the associated my expectations for
	 * @return the my expectations associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.MyExpectation> getMyExpectations(
		long pk) throws SystemException {
		return getMyExpectations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
	}

	/**
	 * Gets a range of all the my expectations associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated my expectations for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of my expectations associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.MyExpectation> getMyExpectations(
		long pk, int start, int end) throws SystemException {
		return getMyExpectations(pk, start, end, null);
	}

	public static final FinderPath FINDER_PATH_GET_MYEXPECTATIONS = new FinderPath(com.vijayan.profile.model.impl.MyExpectationModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.MyExpectationModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.MyExpectationPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getMyExpectations",
			new String[] {
				Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
				"com.liferay.portal.kernel.util.OrderByComparator"
			});

	/**
	 * Gets an ordered range of all the my expectations associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated my expectations for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of my expectations associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.MyExpectation> getMyExpectations(
		long pk, int start, int end, OrderByComparator orderByComparator)
		throws SystemException {
		Object[] finderArgs = new Object[] {
				pk, String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<com.vijayan.profile.model.MyExpectation> list = (List<com.vijayan.profile.model.MyExpectation>)FinderCacheUtil.getResult(FINDER_PATH_GET_MYEXPECTATIONS,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				String sql = null;

				if (orderByComparator != null) {
					sql = _SQL_GETMYEXPECTATIONS.concat(ORDER_BY_CLAUSE)
												.concat(orderByComparator.getOrderBy());
				}
				else {
					sql = _SQL_GETMYEXPECTATIONS;
				}

				SQLQuery q = session.createSQLQuery(sql);

				q.addEntity("kalyan_expectation",
					com.vijayan.profile.model.impl.MyExpectationImpl.class);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				list = (List<com.vijayan.profile.model.MyExpectation>)QueryUtil.list(q,
						getDialect(), start, end);
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<com.vijayan.profile.model.MyExpectation>();
				}

				myExpectationPersistence.cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_GET_MYEXPECTATIONS,
					finderArgs, list);

				closeSession(session);
			}
		}

		return list;
	}

	public static final FinderPath FINDER_PATH_GET_MYEXPECTATIONS_SIZE = new FinderPath(com.vijayan.profile.model.impl.MyExpectationModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.MyExpectationModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.MyExpectationPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getMyExpectationsSize", new String[] { Long.class.getName() });

	/**
	 * Gets the number of my expectations associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the number of associated my expectations for
	 * @return the number of my expectations associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public int getMyExpectationsSize(long pk) throws SystemException {
		Object[] finderArgs = new Object[] { pk };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_MYEXPECTATIONS_SIZE,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				SQLQuery q = session.createSQLQuery(_SQL_GETMYEXPECTATIONSSIZE);

				q.addScalar(COUNT_COLUMN_NAME,
					com.liferay.portal.kernel.dao.orm.Type.LONG);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_GET_MYEXPECTATIONS_SIZE,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	public static final FinderPath FINDER_PATH_CONTAINS_MYEXPECTATION = new FinderPath(com.vijayan.profile.model.impl.MyExpectationModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.MyExpectationModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.MyExpectationPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"containsMyExpectation",
			new String[] { Long.class.getName(), Long.class.getName() });

	/**
	 * Determines whether the my expectation is associated with the profile.
	 *
	 * @param pk the primary key of the profile
	 * @param myExpectationPK the primary key of the my expectation
	 * @return whether the my expectation is associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsMyExpectation(long pk, long myExpectationPK)
		throws SystemException {
		Object[] finderArgs = new Object[] { pk, myExpectationPK };

		Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_MYEXPECTATION,
				finderArgs, this);

		if (value == null) {
			try {
				value = Boolean.valueOf(containsMyExpectation.contains(pk,
							myExpectationPK));
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (value == null) {
					value = Boolean.FALSE;
				}

				FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_MYEXPECTATION,
					finderArgs, value);
			}
		}

		return value.booleanValue();
	}

	/**
	 * Determines whether the profile has any my expectations associated with it.
	 *
	 * @param pk the primary key of the profile to check for associations with my expectations
	 * @return whether the profile has any my expectations associated with it
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsMyExpectations(long pk) throws SystemException {
		if (getMyExpectationsSize(pk) > 0) {
			return true;
		}
		else {
			return false;
		}
	}

	/**
	 * Gets all the family members associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the associated family members for
	 * @return the family members associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.FamilyMember> getFamilyMembers(
		long pk) throws SystemException {
		return getFamilyMembers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
	}

	/**
	 * Gets a range of all the family members associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated family members for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of family members associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.FamilyMember> getFamilyMembers(
		long pk, int start, int end) throws SystemException {
		return getFamilyMembers(pk, start, end, null);
	}

	public static final FinderPath FINDER_PATH_GET_FAMILYMEMBERS = new FinderPath(com.vijayan.profile.model.impl.FamilyMemberModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.FamilyMemberModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.FamilyMemberPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getFamilyMembers",
			new String[] {
				Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
				"com.liferay.portal.kernel.util.OrderByComparator"
			});

	/**
	 * Gets an ordered range of all the family members associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated family members for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of family members associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.FamilyMember> getFamilyMembers(
		long pk, int start, int end, OrderByComparator orderByComparator)
		throws SystemException {
		Object[] finderArgs = new Object[] {
				pk, String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<com.vijayan.profile.model.FamilyMember> list = (List<com.vijayan.profile.model.FamilyMember>)FinderCacheUtil.getResult(FINDER_PATH_GET_FAMILYMEMBERS,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				String sql = null;

				if (orderByComparator != null) {
					sql = _SQL_GETFAMILYMEMBERS.concat(ORDER_BY_CLAUSE)
											   .concat(orderByComparator.getOrderBy());
				}
				else {
					sql = _SQL_GETFAMILYMEMBERS;
				}

				SQLQuery q = session.createSQLQuery(sql);

				q.addEntity("kalyan_family_member",
					com.vijayan.profile.model.impl.FamilyMemberImpl.class);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				list = (List<com.vijayan.profile.model.FamilyMember>)QueryUtil.list(q,
						getDialect(), start, end);
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<com.vijayan.profile.model.FamilyMember>();
				}

				familyMemberPersistence.cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_GET_FAMILYMEMBERS,
					finderArgs, list);

				closeSession(session);
			}
		}

		return list;
	}

	public static final FinderPath FINDER_PATH_GET_FAMILYMEMBERS_SIZE = new FinderPath(com.vijayan.profile.model.impl.FamilyMemberModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.FamilyMemberModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.FamilyMemberPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getFamilyMembersSize", new String[] { Long.class.getName() });

	/**
	 * Gets the number of family members associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the number of associated family members for
	 * @return the number of family members associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public int getFamilyMembersSize(long pk) throws SystemException {
		Object[] finderArgs = new Object[] { pk };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_FAMILYMEMBERS_SIZE,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				SQLQuery q = session.createSQLQuery(_SQL_GETFAMILYMEMBERSSIZE);

				q.addScalar(COUNT_COLUMN_NAME,
					com.liferay.portal.kernel.dao.orm.Type.LONG);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_GET_FAMILYMEMBERS_SIZE,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	public static final FinderPath FINDER_PATH_CONTAINS_FAMILYMEMBER = new FinderPath(com.vijayan.profile.model.impl.FamilyMemberModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.FamilyMemberModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.FamilyMemberPersistenceImpl.FINDER_CLASS_NAME_LIST,
			"containsFamilyMember",
			new String[] { Long.class.getName(), Long.class.getName() });

	/**
	 * Determines whether the family member is associated with the profile.
	 *
	 * @param pk the primary key of the profile
	 * @param familyMemberPK the primary key of the family member
	 * @return whether the family member is associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsFamilyMember(long pk, long familyMemberPK)
		throws SystemException {
		Object[] finderArgs = new Object[] { pk, familyMemberPK };

		Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_FAMILYMEMBER,
				finderArgs, this);

		if (value == null) {
			try {
				value = Boolean.valueOf(containsFamilyMember.contains(pk,
							familyMemberPK));
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (value == null) {
					value = Boolean.FALSE;
				}

				FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_FAMILYMEMBER,
					finderArgs, value);
			}
		}

		return value.booleanValue();
	}

	/**
	 * Determines whether the profile has any family members associated with it.
	 *
	 * @param pk the primary key of the profile to check for associations with family members
	 * @return whether the profile has any family members associated with it
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsFamilyMembers(long pk) throws SystemException {
		if (getFamilyMembersSize(pk) > 0) {
			return true;
		}
		else {
			return false;
		}
	}

	/**
	 * Gets all the horoscopes associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the associated horoscopes for
	 * @return the horoscopes associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.Horoscope> getHoroscopes(long pk)
		throws SystemException {
		return getHoroscopes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
	}

	/**
	 * Gets a range of all the horoscopes associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated horoscopes for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @return the range of horoscopes associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.Horoscope> getHoroscopes(long pk,
		int start, int end) throws SystemException {
		return getHoroscopes(pk, start, end, null);
	}

	public static final FinderPath FINDER_PATH_GET_HOROSCOPES = new FinderPath(com.vijayan.profile.model.impl.HoroscopeModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.HoroscopeModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.HoroscopePersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getHoroscopes",
			new String[] {
				Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
				"com.liferay.portal.kernel.util.OrderByComparator"
			});

	/**
	 * Gets an ordered range of all the horoscopes associated with the profile.
	 *
	 * <p>
	 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
	 * </p>
	 *
	 * @param pk the primary key of the profile to get the associated horoscopes for
	 * @param start the lower bound of the range of profiles to return
	 * @param end the upper bound of the range of profiles to return (not inclusive)
	 * @param orderByComparator the comparator to order the results by
	 * @return the ordered range of horoscopes associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public List<com.vijayan.profile.model.Horoscope> getHoroscopes(long pk,
		int start, int end, OrderByComparator orderByComparator)
		throws SystemException {
		Object[] finderArgs = new Object[] {
				pk, String.valueOf(start), String.valueOf(end),
				String.valueOf(orderByComparator)
			};

		List<com.vijayan.profile.model.Horoscope> list = (List<com.vijayan.profile.model.Horoscope>)FinderCacheUtil.getResult(FINDER_PATH_GET_HOROSCOPES,
				finderArgs, this);

		if (list == null) {
			Session session = null;

			try {
				session = openSession();

				String sql = null;

				if (orderByComparator != null) {
					sql = _SQL_GETHOROSCOPES.concat(ORDER_BY_CLAUSE)
											.concat(orderByComparator.getOrderBy());
				}
				else {
					sql = _SQL_GETHOROSCOPES;
				}

				SQLQuery q = session.createSQLQuery(sql);

				q.addEntity("kalyan_horoscope",
					com.vijayan.profile.model.impl.HoroscopeImpl.class);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				list = (List<com.vijayan.profile.model.Horoscope>)QueryUtil.list(q,
						getDialect(), start, end);
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (list == null) {
					list = new ArrayList<com.vijayan.profile.model.Horoscope>();
				}

				horoscopePersistence.cacheResult(list);

				FinderCacheUtil.putResult(FINDER_PATH_GET_HOROSCOPES,
					finderArgs, list);

				closeSession(session);
			}
		}

		return list;
	}

	public static final FinderPath FINDER_PATH_GET_HOROSCOPES_SIZE = new FinderPath(com.vijayan.profile.model.impl.HoroscopeModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.HoroscopeModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.HoroscopePersistenceImpl.FINDER_CLASS_NAME_LIST,
			"getHoroscopesSize", new String[] { Long.class.getName() });

	/**
	 * Gets the number of horoscopes associated with the profile.
	 *
	 * @param pk the primary key of the profile to get the number of associated horoscopes for
	 * @return the number of horoscopes associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public int getHoroscopesSize(long pk) throws SystemException {
		Object[] finderArgs = new Object[] { pk };

		Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_HOROSCOPES_SIZE,
				finderArgs, this);

		if (count == null) {
			Session session = null;

			try {
				session = openSession();

				SQLQuery q = session.createSQLQuery(_SQL_GETHOROSCOPESSIZE);

				q.addScalar(COUNT_COLUMN_NAME,
					com.liferay.portal.kernel.dao.orm.Type.LONG);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(pk);

				count = (Long)q.uniqueResult();
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (count == null) {
					count = Long.valueOf(0);
				}

				FinderCacheUtil.putResult(FINDER_PATH_GET_HOROSCOPES_SIZE,
					finderArgs, count);

				closeSession(session);
			}
		}

		return count.intValue();
	}

	public static final FinderPath FINDER_PATH_CONTAINS_HOROSCOPE = new FinderPath(com.vijayan.profile.model.impl.HoroscopeModelImpl.ENTITY_CACHE_ENABLED,
			com.vijayan.profile.model.impl.HoroscopeModelImpl.FINDER_CACHE_ENABLED,
			com.vijayan.profile.service.persistence.HoroscopePersistenceImpl.FINDER_CLASS_NAME_LIST,
			"containsHoroscope",
			new String[] { Long.class.getName(), Long.class.getName() });

	/**
	 * Determines whether the horoscope is associated with the profile.
	 *
	 * @param pk the primary key of the profile
	 * @param horoscopePK the primary key of the horoscope
	 * @return whether the horoscope is associated with the profile
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsHoroscope(long pk, long horoscopePK)
		throws SystemException {
		Object[] finderArgs = new Object[] { pk, horoscopePK };

		Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_HOROSCOPE,
				finderArgs, this);

		if (value == null) {
			try {
				value = Boolean.valueOf(containsHoroscope.contains(pk,
							horoscopePK));
			}
			catch (Exception e) {
				throw processException(e);
			}
			finally {
				if (value == null) {
					value = Boolean.FALSE;
				}

				FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_HOROSCOPE,
					finderArgs, value);
			}
		}

		return value.booleanValue();
	}

	/**
	 * Determines whether the profile has any horoscopes associated with it.
	 *
	 * @param pk the primary key of the profile to check for associations with horoscopes
	 * @return whether the profile has any horoscopes associated with it
	 * @throws SystemException if a system exception occurred
	 */
	public boolean containsHoroscopes(long pk) throws SystemException {
		if (getHoroscopesSize(pk) > 0) {
			return true;
		}
		else {
			return false;
		}
	}

	/**
	 * Initializes the profile persistence.
	 */
	public void afterPropertiesSet() {
		String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
					com.liferay.util.service.ServiceProps.get(
						"value.object.listener.com.vijayan.profile.model.Profile")));

		if (listenerClassNames.length > 0) {
			try {
				List<ModelListener<Profile>> listenersList = new ArrayList<ModelListener<Profile>>();

				for (String listenerClassName : listenerClassNames) {
					listenersList.add((ModelListener<Profile>)InstanceFactory.newInstance(
							listenerClassName));
				}

				listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
			}
			catch (Exception e) {
				_log.error(e);
			}
		}

		containsMyPhoto = new ContainsMyPhoto(this);

		containsMyExpectation = new ContainsMyExpectation(this);

		containsFamilyMember = new ContainsFamilyMember(this);

		containsHoroscope = new ContainsHoroscope(this);
	}

	@BeanReference(type = ProfilePersistence.class)
	protected ProfilePersistence profilePersistence;
	@BeanReference(type = MyExpectationPersistence.class)
	protected MyExpectationPersistence myExpectationPersistence;
	@BeanReference(type = FamilyMemberPersistence.class)
	protected FamilyMemberPersistence familyMemberPersistence;
	@BeanReference(type = HoroscopePersistence.class)
	protected HoroscopePersistence horoscopePersistence;
	@BeanReference(type = MyPhotoPersistence.class)
	protected MyPhotoPersistence myPhotoPersistence;
	@BeanReference(type = ResourcePersistence.class)
	protected ResourcePersistence resourcePersistence;
	@BeanReference(type = UserPersistence.class)
	protected UserPersistence userPersistence;
	protected ContainsMyPhoto containsMyPhoto;
	protected ContainsMyExpectation containsMyExpectation;
	protected ContainsFamilyMember containsFamilyMember;
	protected ContainsHoroscope containsHoroscope;

	protected class ContainsMyPhoto {
		protected ContainsMyPhoto(ProfilePersistenceImpl persistenceImpl) {
			super();

			_mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
					_SQL_CONTAINSMYPHOTO,
					new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
					RowMapper.COUNT);
		}

		protected boolean contains(long profileId, long photoId) {
			List<Integer> results = _mappingSqlQuery.execute(new Object[] {
						new Long(profileId), new Long(photoId)
					});

			if (results.size() > 0) {
				Integer count = results.get(0);

				if (count.intValue() > 0) {
					return true;
				}
			}

			return false;
		}

		private MappingSqlQuery<Integer> _mappingSqlQuery;
	}

	protected class ContainsMyExpectation {
		protected ContainsMyExpectation(ProfilePersistenceImpl persistenceImpl) {
			super();

			_mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
					_SQL_CONTAINSMYEXPECTATION,
					new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
					RowMapper.COUNT);
		}

		protected boolean contains(long profileId, long exceptationId) {
			List<Integer> results = _mappingSqlQuery.execute(new Object[] {
						new Long(profileId), new Long(exceptationId)
					});

			if (results.size() > 0) {
				Integer count = results.get(0);

				if (count.intValue() > 0) {
					return true;
				}
			}

			return false;
		}

		private MappingSqlQuery<Integer> _mappingSqlQuery;
	}

	protected class ContainsFamilyMember {
		protected ContainsFamilyMember(ProfilePersistenceImpl persistenceImpl) {
			super();

			_mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
					_SQL_CONTAINSFAMILYMEMBER,
					new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
					RowMapper.COUNT);
		}

		protected boolean contains(long profileId, long memberId) {
			List<Integer> results = _mappingSqlQuery.execute(new Object[] {
						new Long(profileId), new Long(memberId)
					});

			if (results.size() > 0) {
				Integer count = results.get(0);

				if (count.intValue() > 0) {
					return true;
				}
			}

			return false;
		}

		private MappingSqlQuery<Integer> _mappingSqlQuery;
	}

	protected class ContainsHoroscope {
		protected ContainsHoroscope(ProfilePersistenceImpl persistenceImpl) {
			super();

			_mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
					_SQL_CONTAINSHOROSCOPE,
					new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
					RowMapper.COUNT);
		}

		protected boolean contains(long profileId, long horoscopeId) {
			List<Integer> results = _mappingSqlQuery.execute(new Object[] {
						new Long(profileId), new Long(horoscopeId)
					});

			if (results.size() > 0) {
				Integer count = results.get(0);

				if (count.intValue() > 0) {
					return true;
				}
			}

			return false;
		}

		private MappingSqlQuery<Integer> _mappingSqlQuery;
	}

	private static final String _SQL_SELECT_PROFILE = "SELECT profile FROM Profile profile";
	private static final String _SQL_SELECT_PROFILE_WHERE = "SELECT profile FROM Profile profile WHERE ";
	private static final String _SQL_COUNT_PROFILE = "SELECT COUNT(profile) FROM Profile profile";
	private static final String _SQL_COUNT_PROFILE_WHERE = "SELECT COUNT(profile) FROM Profile profile WHERE ";
	private static final String _SQL_GETMYPHOTOS = "SELECT {kalyan_photo.*} FROM kalyan_photo INNER JOIN kalyan_profile ON (kalyan_profile.profileId = kalyan_photo.profileId) WHERE (kalyan_profile.profileId = ?)";
	private static final String _SQL_GETMYPHOTOSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_photo WHERE profileId = ?";
	private static final String _SQL_CONTAINSMYPHOTO = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_photo WHERE profileId = ? AND photoId = ?";
	private static final String _SQL_GETMYEXPECTATIONS = "SELECT {kalyan_expectation.*} FROM kalyan_expectation INNER JOIN kalyan_profile ON (kalyan_profile.profileId = kalyan_expectation.profileId) WHERE (kalyan_profile.profileId = ?)";
	private static final String _SQL_GETMYEXPECTATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_expectation WHERE profileId = ?";
	private static final String _SQL_CONTAINSMYEXPECTATION = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_expectation WHERE profileId = ? AND exceptationId = ?";
	private static final String _SQL_GETFAMILYMEMBERS = "SELECT {kalyan_family_member.*} FROM kalyan_family_member INNER JOIN kalyan_profile ON (kalyan_profile.profileId = kalyan_family_member.profileId) WHERE (kalyan_profile.profileId = ?)";
	private static final String _SQL_GETFAMILYMEMBERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_family_member WHERE profileId = ?";
	private static final String _SQL_CONTAINSFAMILYMEMBER = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_family_member WHERE profileId = ? AND memberId = ?";
	private static final String _SQL_GETHOROSCOPES = "SELECT {kalyan_horoscope.*} FROM kalyan_horoscope INNER JOIN kalyan_profile ON (kalyan_profile.profileId = kalyan_horoscope.profileId) WHERE (kalyan_profile.profileId = ?)";
	private static final String _SQL_GETHOROSCOPESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_horoscope WHERE profileId = ?";
	private static final String _SQL_CONTAINSHOROSCOPE = "SELECT COUNT(*) AS COUNT_VALUE FROM kalyan_horoscope WHERE profileId = ? AND horoscopeId = ?";
	private static final String _FINDER_COLUMN_PROFILECODE_PROFILECODE_1 = "profile.profileCode IS NULL";
	private static final String _FINDER_COLUMN_PROFILECODE_PROFILECODE_2 = "profile.profileCode = ?";
	private static final String _FINDER_COLUMN_PROFILECODE_PROFILECODE_3 = "(profile.profileCode IS NULL OR profile.profileCode = ?)";
	private static final String _FINDER_COLUMN_USERID_ADDEDBY_2 = "profile.addedBy = ?";
	private static final String _FINDER_COLUMN_ADDEDBY_ADDEDBY_2 = "profile.addedBy = ?";
	private static final String _FINDER_COLUMN_STATUS_STATUS_2 = "profile.status = ?";
	private static final String _ORDER_BY_ENTITY_ALIAS = "profile.";
	private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Profile exists with the primary key ";
	private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Profile exists with the key {";
	private static Log _log = LogFactoryUtil.getLog(ProfilePersistenceImpl.class);
}